<?php
	$time_start = microtime(true);
	require_once("../index.php"); //@todo this could be an issue - need to rethink
	
	//caching ignore list
	$ignore_list = array('/web'); //@todo rather this was in config file - but how to read?
	//$ignore_list = array();
	
	$page = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // Requested page
  	$cachefile = CACHEDIR . md5($page) . '.' . CACHEEXT; // Cache file to either load or create
  	
  	$ignore_page = false;
  for ($i = 0; $i < count($ignore_list); $i++) {
    $ignore_page = (strpos($page, $ignore_list[$i]) !== false) ? true : $ignore_page;
  }

  $cachefile_created = ((@file_exists($cachefile)) and ($ignore_page === false)) ? @filemtime($cachefile) : 0;
  @clearstatcache();

  // Show file from cache if still valid
  if (time() - CACHETIME < $cachefile_created) {

    //ob_start('ob_gzhandler');
    @readfile($cachefile);
    //ob_end_flush();
    exit();

  }

  // If we're still here, we need to generate a cache file
  	
  	
  	ob_start("ob_gzhandler");
  	$html->head();
	
?>
